package demo.protocolEncodeDecode;

import java.nio.charset.Charset;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

/**
 * 编解码工厂
 * @author eg366
 *
 */
public class SmsCodecFactory implements ProtocolCodecFactory {
	
	private final SmsEncoder encoder;
//	private final SmsDecoder decoder;
	private final CmccSipcDecoder decoder;
	
	public SmsCodecFactory() {
		this(Charset.defaultCharset());
	}
	
	public SmsCodecFactory (Charset charset) {
		encoder = new SmsEncoder(charset);
		decoder = new CmccSipcDecoder(charset);
	}
	

	public ProtocolEncoder getEncoder(IoSession session) throws Exception {
		return encoder;
	}

	public ProtocolDecoder getDecoder(IoSession session) throws Exception {
		return decoder;
	}

}
